<template>
  <div class="patient-info-card">
    <!-- 标题栏 -->
    <div class="card-header">
      <span class="card-title">病历信息</span>
      <el-button class="query-btn" @click="handleViewRecord"
        >查看病历</el-button
      >
    </div>

    <!-- 信息内容 -->
    <div class="info-content">
      <div class="info-row">
        <div class="info-item">
          <span class="label">主诉</span>
          <span class="value">{{ patientDetail.complaint }}</span>
        </div>
      </div>

      <div class="info-row">
        <div class="info-item full-width">
          <span class="label">最后诊断</span>
          <span class="value">{{ patientDetail.diagnosis }}</span>
        </div>
      </div>

      <div class="info-row">
        <div class="info-item">
          <span class="label">诊断医生</span>
          <span class="value">{{ patientDetail.doctorName }}</span>
        </div>
        <div class="info-item">
          <span class="label">诊断时间</span>
          <span class="value">{{ patientDetail.diagnosisTime }}</span>
        </div>
      </div>
    </div>
    <BottomDrawer
      :visible="visiblePrint"
      :title="''"
      :width="1200"
      top="2vh"
      :showFooter="false"
      @close="visiblePrint = false"
    >
      <div style="height: 750px;overflow: auto;">
            <viewmedicalRecord
        :medicalRecordList="medicalRecordList"
      ></viewmedicalRecord>
      </div>
    </BottomDrawer>
  </div>
</template>

<script lang="ts" setup>
import viewmedicalRecord from './viewmedicalRecord.vue';
import { getMedicalDetail } from '@/api/medical';
const visiblePrint = ref(false);
const props = defineProps<{
  patientDetail?: any;
}>();
const medicalRecordList = ref([]);
// 这里可以添加查看病历的方法
const handleViewRecord = async () => {
  //console.log('查看病历');
  const res = await getMedicalDetail({
    medicalId: props.patientDetail.medicalId,
  });
  // 实现查看病历的逻辑
  if (res.code == '200') {
    medicalRecordList.value = res.data;
    visiblePrint.value = true;
  } else {
    //ElMessage.error(res.msg);
  }
  // props.patientDetail.medicalId
};
</script>

<style scoped lang="scss">
.patient-info-card {
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  width: 100%;
  min-height: 120px;
  overflow: hidden;
}

.card-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-family: Microsoft YaHei, sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: #2c3e50;
}

.query-btn {
  font-size: 12px;
  padding: 4px 12px;
  height: 28px;
  border-radius: 4px;
  color: var(--el-color-primary);
}

.info-content {
  padding: 0;
  border-top: 1px solid #e5e5e5;
}

.info-row {
  display: flex;

  &:not(:last-child) {
    border-bottom: 1px solid #e5e5e5;
  }
}

.info-item {
  display: flex;
  flex: 1;
  padding: 0 16px;

  &.full-width {
    flex: 1 1 100%;
  }

  &:not(:last-child) {
    border-right: 1px solid #e5e5e5;
  }
}

.label {
  font-family: Microsoft YaHei, sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #666666;
  min-width: 70px;
  padding: 12px 12px 12px 0;
  flex-shrink: 0;
  border-right: 1px solid #e5e5e5;
  margin-right: 0;
}

.value {
  font-family: Microsoft YaHei, sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #333333;
  flex: 1;
  word-break: break-all;
  padding: 12px 0 12px 12px;
}

// 响应式设计
@media (max-width: 768px) {
  .info-row {
    flex-direction: column;
  }

  .info-item {
    border-right: none !important;
    border-bottom: 1px solid #e5e5e5;

    &:last-child {
      border-bottom: none;
    }
  }
}
</style>
